<?php
require_once(dirname(__FILE__)."/config.php");
CheckRank(0,0);
require_once(DEDEINC."/datalistcp.class.php");
setcookie("ENV_GOBACK_URL",GetCurUrl(),time()+3600,"/");
$action = isset($action) ? trim($action) : '';
$tpl = '';




if(empty($solei))
{
     $solei = 'soip';
}

if(empty($soso))
{
     $soso = '';
}

if(empty($solei))
{
     $solei = '';
}




if($action == '')
{

        $tgip = $soso;
        $orderby = empty($orderby) ? 'id' : eregi_replace('[^a-z]','',$orderby);
	$orderway = isset($orderway) && $orderway == 'asc' ? 'asc' : 'desc';
	if($solei == 'soip')
	{
		$where = " where tgip like '%$tgip%'";
	}
	else
	{
                $where = " where lailu like '%$tgip%'";
	}
	$neworderway = ($orderway == 'desc' ? 'asc' : 'desc');
        $query = "Select * from `#@__tgip` $where order by $orderby $orderway";
	$dlist = new DataListCP();
	$tgip = stripslashes($tgip);
	$dlist->SetParameter("tgip",$tgip);
	$dlist->SetParameter("orderway",$orderway);
	$dlist->SetParameter("orderby",$orderby);
	$dlist->pageSize = 10;
	$dlist->SetTemplet(DEDEMEMBER.'/templets/tgreg.htm');
	$dlist->SetSource($query);
	$dlist->Display();
exit;
}












if($action == 'delete')
{

if($dels == 'dels')

   
//---------------------

{
	//这里要写个是否删除提示

	$query = "delete from `#@__tgip` where id=150 and userid='$cfg_ml->M_ID'";
	if($dsql->ExecuteNoneQuery($query))
	{
		//$query = "delete from `#@__tgip` where id=0";  
		$dsql->ExecuteNoneQuery($query);
		ShowMsg("已经全部清除成功!", 'tgreg.php');
	}
	else
	{
		ShowMsg("清除失败!", 'tgreg.php');
	}
     
}
//--------------------------
	






//---------------------

else


//---------------
{

	if(@is_array($id))
	{
		$tgipids = implode(',', $id);
	}
	elseif(!empty($id))
	{
		$tgipids = $id;
	}
	else
	{
                ShowMsg('没有选择要删除的项!','-1');
		exit();
	}
	$query = "delete from `#@__tgip` where id in ($tgipids)";
	if($dsql->ExecuteNoneQuery($query))
	{
		$query = "delete from `#@__tgip` where id in ($tgipids)";
		$dsql->ExecuteNoneQuery($query);
		ShowMsg("删除[ $tgipids ]项成功", 'tgreg.php');
	}
	else
	{
		ShowMsg("删除[ $tgipids ]项失败", 'tgreg.php');
	}

        exit();
}

//----------------------------




}



else if($action == 'soso')
{

        $tgip = $soso;
        $orderby = empty($orderby) ? 'id' : eregi_replace('[^a-z]','',$orderby);
	$orderway = isset($orderway) && $orderway == 'asc' ? 'asc' : 'desc';
	if($solei == 'soip')
	{
		$where = " where tgip like '%$tgip%'";
	}
	else
	{
                $where = " where lailu like '%$tgip%'";
	}
	$neworderway = ($orderway == 'desc' ? 'asc' : 'desc');
        $query = "Select * from `#@__tgip` $where order by $orderby $orderway";
	$dlist = new DataListCP();
	$tgip = stripslashes($tgip);
	$dlist->SetParameter("tgip",$tgip);
	$dlist->SetParameter("orderway",$orderway);
	$dlist->SetParameter("orderby",$orderby);
	$dlist->pageSize = 10;
	$dlist->SetTemplet(DEDEMEMBER.'/templets/tgreg.htm');
	$dlist->SetSource($query);
	$dlist->Display();
exit;
}













else if ($action == 'add')

{
       


$row = $dsql->GetOne("Select userid From `#@__tgreg` where userid like '$cfg_ml->M_ID' ");
if(is_array($row))
	{
		ShowMsg('对不起，你已经开通了', '-1');
		exit();
	}

else
{
        $regtime =time();//获取时间
	$query = "insert into `#@__tgreg`(userid, username, regtime) values ('$cfg_ml->M_ID', '$cfg_ml->M_UserName', '$regtime'); ";
	if($dsql->ExecuteNoneQuery($query))
	{
		ShowMsg('开通成功', 'tgreg.php');
	}
	else
	{
		ShowMsg('开通失败', '-1');
	}
	exit();
}

}













?>